﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using VietImage.Models;
using VietImage.ViewModels;

namespace VietImage.Controllers
{
    public class CategoryController : Controller
    {
        //
        // GET: /Category/
        public void GetLanguage()
        {
            HttpCookie languageCookie = null;
            if (languageCookie == null)
            {
                languageCookie = new HttpCookie("Language");
                languageCookie.Value = "2";
            }
            languageCookie.Expires = DateTime.Now.AddMonths(1);
            //Response.SetCookie(languageCookie);
            ViewData["Language"] = int.Parse(languageCookie.Value);
        }

        Category cat = new Category();

        public ActionResult Index()
        {
            GetLanguage();
            return View(cat);
        }

        public ActionResult ReportageBrowse()
        {
            GetLanguage();
            cat = Category.GetCategory(254);
            return View("ReportageBrowse", cat);
        }

        public ActionResult SubReportageBrowse(int id = 254)
        {
            GetLanguage();
            cat = Category.GetCategory(id);
            return View("SubReportageBrowse", cat);
        }

        public ActionResult ReportageDetail(int id = 254)
        {
            GetLanguage();
            cat = Category.GetCategory(id);
            return View("ReportageDetail", cat);
        }

        public ActionResult Detail(int id)
        {
            GetLanguage();
            cat = Category.GetCategory(id);
            if (id == 254)
            {
                return View("ReportageBrowse", cat);
            }
            if (cat.IsParent)
                return View("Index", cat);
            return View("Detail", cat);
        }

    }
}
